package com.demo.Controller;

import com.alibaba.fastjson.JSONObject;
import com.demo.Pojo.Books;
import com.demo.service.FeignBookService;
import com.demo.service.FeignBookServiceFall;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 测试服务降级
 */

@RestController
public class FeignContorllerFall {

    @Resource
    public FeignBookServiceFall service;

    @RequestMapping("/getAllBook")
    public JSONObject getAll(){
        return service.queryAll();
    }

    @RequestMapping("/getBookById/{id}")
    public Books queryBookById(@PathVariable("id") int id){
        Books books = service.queryById(id);
        return books;
    }
}
